package net.zoneland.geological.station.service;


import org.apache.log4j.Logger;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

import java.util.UUID;

import net.zoneland.geological.station.entity.Tbl_station_type;
import net.zoneland.geological.station.dao.Tbl_station_typeDao;

import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * tbl_station_type[设备类型信息]表操作Serfice实现类

 * 表   名：TBL_STATION_TYPESERVICEIMPL<br/>
 * 注   释：设备类型信息<br/>
 * 作   者：李义<br/>
 * 日   期：2017-06-03 07:17:47
**/
@Service("tbl_station_typeService")
public class Tbl_station_typeServiceImpl implements Tbl_station_typeServiceI { 

	public static Logger logger = Logger.getLogger(Tbl_station_typeServiceImpl.class);

	/**
	 * 自动注入DAO对象
	**/
	@Autowired
	private Tbl_station_typeDao tbl_station_typeDao;

	/**
	 * 新增或者更新数据方法接口
	**/
	@Override
	public Tbl_station_type addOrUpdate( Tbl_station_type tbl_station_type )  throws Exception{
		if ( tbl_station_type == null ) {
			logger.error(Tbl_station_type.class.getName() + "对象参数信息为NULL，addOrUpdate方法无法继续！");
			return tbl_station_type;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		if( tbl_station_type.getId() ==null || "".equals( tbl_station_type.getId().trim() ) ){
			map.put( "id", "0000-0000-0000-0000" );
		}else{
			map.put( "id", tbl_station_type.getId() );
		}
		List<Tbl_station_type> list  = tbl_station_typeDao.getList(map);
		if( list != null && !list.isEmpty() ){
			tbl_station_typeDao.edit( tbl_station_type );
			return tbl_station_type;
		}else{
			if( tbl_station_type.getId() ==null || tbl_station_type.getId().trim().isEmpty() ){
				tbl_station_type.setId( UUID.randomUUID() + "" );
		    }
			tbl_station_typeDao.add( tbl_station_type );
			return tbl_station_type;
		}
	}
	/**
	 * 新增数据方法实现
	**/
	@Override
	public boolean add(Tbl_station_type tbl_station_type) throws Exception{
		tbl_station_typeDao.add( tbl_station_type );
		return true;
	}
	/**
	 * 更新数据方法实现
	**/
	@Override
	public boolean update(Tbl_station_type tbl_station_type) throws Exception{
		tbl_station_typeDao.edit( tbl_station_type );
		return true;
	}
	/**
	 * 查询数据方法实现
	**/
	@Override
	public Tbl_station_type get( Map<String, Object> map ) throws Exception{
		return tbl_station_typeDao.get( map );
	}
	/**
	 * 查询数据方法实现（列表）
	**/
	@Override
	public List<Tbl_station_type> getList(Map<String, Object> map) throws Exception{ 
		return tbl_station_typeDao.getList( map );
	}
	
	/**
	 * 查询数据总数方法实现
	**/
	@Override
	public int getListCount(Map<String, Object> map) throws Exception{ 
		return tbl_station_typeDao.getListCount( map );
	}
	
	/**
	 * 数据删除方法实现
	**/
	@Override
	public boolean delete(Map<String, Object> map) throws Exception{ 
		tbl_station_typeDao.delete( map );
		return true;
	}
	
}
